package com.xiaozhaovip.demo.Enum;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 活动地址形式枚举
 *
 * @author Cauli
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum YueQiLaiTypeEnum {
    OnLine(0, "线上"),
    OffLine(1, "线下");

    private int id;
    private String name;

    /**
     * 通过 id 得到活动地址形式
     *
     * @param id
     * @return
     */
    public static YueQiLaiTypeEnum getById(int id) {
        for (YueQiLaiTypeEnum typeEnum : YueQiLaiTypeEnum.values()) {
            if (id == typeEnum.id) {
                return typeEnum;
            }
        }
        return null;
    }

    /**
     * 返回所有活动地址形式
     *
     * @return
     */
    public static List<YueQiLaiTypeEnum> getAllTypes() {
        List<YueQiLaiTypeEnum> list = new ArrayList<>();
        for (YueQiLaiTypeEnum typeEnum : YueQiLaiTypeEnum.values()) {
            list.add(typeEnum);
        }
        return list;
    }
}
